<?php

class Testpdf_posgrado extends CI_Controller {

    /**
     * El Constructor de la clase
     */
    function __construct() {
        parent::__construct();
        $this->load->helper('comunes_helper');
    }

    /**
     * Generar el Documento final de la carrera
     * @param Strign $carrera La carrera del documento a generar
     */
    function index($carrera,$distrito) {
        $this->load->library('mpdf');
        $this->mpdf->StartProgressBarOutput(2);
        //$this->mpdf->SetDefaultFont('DejaVuSansMono');
        $this->mpdf->SetDefaultFont('FreeMono');
        $this->mpdf->SetDefaultFontSize(14);
        $this->mpdf->SetDisplayMode('fullpage', 'two');
        $this->mpdf->SetHTMLHeader('');

        $this->load->model('reporte_model_posgrado', 'reporte');
        $this->reporte->programa = $carrera;
        $this->reporte->distrito = $distrito;
        
        $this->reporte->generatodo();
        //$this->mpdf->Output();
        $this->mpdf->Output($this->reporte->programa.' - '.$this->reporte->distrito.'.pdf','D');
        //$this->mpdf->Output();
    }

    function reposicion(){
        $this->load->library('mpdf');
        $this->mpdf->StartProgressBarOutput(2);
        //$this->mpdf->SetDefaultFont('DejaVuSansMono');
        $this->mpdf->SetDefaultFont('FreeMono');
        $this->mpdf->SetDefaultFontSize(14);
        $this->mpdf->SetDisplayMode('fullpage', 'two');
        $this->mpdf->SetHTMLHeader('');

        $this->load->model('reporte_model', 'reporte');

        $dbres = $this->db->get('GENERAL');
        foreach ($dbres->result_array() as $tablerow) {
          $this->reporte->programa = $tablerow['PROGRAMA'];
          $this->reporte->distrito = $tablerow['DIST'];
          $this->reporte->hoja3();
          $this->reporte->hoja4();
          $this->reporte->hoja7();
          $this->reporte->hoja8();
        }

        $this->mpdf->Output($this->reporte->programa.' - '.$this->reporte->distrito.'.pdf','D');

    }

}